import request from '@/config/axios'

// 积分信息 VO
export interface PointsVO {
  id?: number // 积分ID
  userId: number // 用户ID
  points: number // 积分余额
  vipLevel: number // VIP等级
  createTime?: string // 创建时间
}

// 积分信息响应 VO
export interface PointsRespVO {
  id: number // 积分ID
  userId: number // 用户ID
  userName: string // 用户名称
  points: number // 积分余额
  vipLevel: number // VIP等级
  createTime: string // 创建时间
}

// 积分信息 API
export const PointsApi = {
  // 查询积分信息分页
  getPointsPage: async (params: any) => {
    return await request.get({ url: `/points/page`, params })
  },

  // 查询积分信息详情
  getPoints: async (id: number) => {
    return await request.get({ url: `/points/get?id=` + id })
  },

  // 新增积分信息
  createPoints: async (data: PointsVO) => {
    return await request.post({ url: `/points/create`, data })
  },

  // 修改积分信息
  updatePoints: async (data: PointsVO) => {
    return await request.put({ url: `/points/update`, data })
  },

  // 删除积分信息
  deletePoints: async (id: number) => {
    return await request.delete({ url: `/points/delete?id=` + id })
  },

  // 导出积分信息 Excel
  exportPoints: async (params) => {
    return await request.download({ url: `/points/export-excel`, params })
  },

  // 根据用户id获取折扣
  getByUserId: async () => {
    return await request.get({ url: `/user/points/getByUserId` })
  }
}
